package com.soxing.braindata.common.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Data
@Configuration
@ConfigurationProperties(prefix = "file")
public class FileConfig implements WebMvcConfigurer {

    /**
     * 文件访问路径
     */
    private String path;
    /**
     * 文件保存路径
     */
    private String address;
    /**
     * 每个目录最大文件数
     */
    private int maxFiles;
    /**
     * 密钥
     */
    private String secretKey;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(path + "/**").addResourceLocations("file:" + address + "/");
    }

}
